package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.domain.KnowledgeUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface KnowledgeDao {


    //评估建议相关*************************************************************

   //  此处没用注解，使用KnowledgeMpper.xml 进行分页查询和条件查询
    Page<KnowledgeUser> selectByConditionAdvice(String queryString);//-----分页查询+条件

  @Select("select * from t_pathogeny_knowledge where LoreID=#{LoreID} ")
    KnowledgeUser findByIdAdvice(Integer LoreID);                //根据id查数据

    @Insert("INSERT INTO t_pathogeny_knowledge (Title,Keyword,LoreType,LoreContent) " +
            "VALUES(#{Title},#{Keyword},#{LoreType},#{LoreContent})")
    void addAdvice(KnowledgeUser knowledgeUser);                 //增加数据

    @Update("update t_pathogeny_knowledge set Title=#{Title},Keyword=#{Keyword},LoreType=#{LoreType},LoreContent=#{LoreContent} where LoreID=#{LoreID}")
    void updateAdvice(KnowledgeUser knowledgeUser);              //修改数据

    @Delete("delete from t_pathogeny_knowledge where LoreID=#{id}")
    void  deleteAdvice(Integer id);//删除
    //*************************************************************

    //运动项目库相关+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Page<KnowledgeUser> selectByConditionSport(String queryString);  //分页查询+条件

  @Select("select * from t_sport_knowledge where Number=#{Number} ")
  KnowledgeUser findByIdSport(Integer Number);                //根据id查数据

    @Insert("INSERT INTO t_sport_knowledge (SportNumber,SportName,SportTime,Strength,KilostepEquivalent,MinAge,MaxAge) " +
            "VALUES(#{SportNumber},#{SportName},#{SportTime},#{Strength},#{KilostepEquivalent},#{MinAge},#{MaxAge})")
    void addSport(KnowledgeUser knowledgeUser);                 //增加数据

    @Update("update t_sport_knowledge set SportNumber=#{SportNumber},SportName=#{SportName},Strength=#{Strength},KilostepEquivalent=#{KilostepEquivalent},SportTime=#{SportTime},MinAge=#{MinAge},MaxAge=#{MaxAge} where Number=#{Number}")
    void updateSport(KnowledgeUser knowledgeUser);              //修改数据

    @Delete("delete from t_sport_knowledge where Number=#{id}")
    void  deleteSport(Integer id);                               //删除
    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    //膳食库相关--------------------------------------------------------
    Page<KnowledgeUser> selectByCondition(String queryString); //分页查询+条件

    @Select("select * from t_food_knowledge where FoodID=#{FoodID}")
    KnowledgeUser findById(Integer FoodID);                //根据id查数据

    @Insert("INSERT INTO t_food_knowledge (FoodID,FoodName,FoodTip,FoodWater,FoodKJ,FoodProtein,FoodFat) " +
            "VALUES(#{FoodID},#{FoodName},#{FoodTip},#{FoodWater},#{FoodKJ},#{FoodProtein},#{FoodFat})")
    void add(KnowledgeUser knowledgeUser);                  //增加数据

    @Update("update t_food_knowledge set FoodName=#{FoodName},FoodTip=#{FoodTip },FoodWater=#{FoodWater},FoodKJ=#{FoodKJ},FoodProtein=#{FoodProtein},FoodFat=#{FoodFat} where FoodID=#{FoodID}")
    void update(KnowledgeUser knowledgeUser);               //修改数据

    @Delete("delete from t_food_knowledge where FoodID=#{id}")
    void  delete(Integer id);                                //删除
    //-----------------------------------------------------------------

  //项目库相关--------------------------------------------------------
  Page<KnowledgeUser> selectByConditionItem(String queryString); //分页查询+条件

  @Select("select * from t_item_knowledge where ItemID=#{ItemID}")
  KnowledgeUser findByIdItem(Integer ItemID);                //根据id查数据

  @Insert("INSERT INTO t_item_knowledge (ItemName,HelpChar,Sex,MinAge,MaxAge,ItemType,Unit) " +
          "VALUES(#{ItemName},#{HelpChar},#{Sex},#{MinAge},#{MaxAge},#{ItemType},#{Unit})")
  void addItem(KnowledgeUser knowledgeUser);                  //增加数据

  @Update("update t_item_knowledge set ItemName=#{ItemName},HelpChar=#{HelpChar},Sex=#{Sex},MinAge=#{MinAge},MaxAge=#{MaxAge},ItemType=#{ItemType},Unit=#{Unit} where ItemID=#{ItemID}")
  void updateItem(KnowledgeUser knowledgeUser);               //修改数据

  @Delete("delete from t_item_knowledge where ItemID=#{ItemID}")
  void  deleteItem(Integer ItemID);                                //删除


  //-----------------------------------------------------------------

}
